package com.deanlib.cabinet.ui.view;

import com.deanlib.cabinet.R;
import com.deanlib.cabinet.base.BaseActivity;
import com.deanlib.cabinet.data.AppDatabase;
import com.deanlib.cabinet.data.event.UserStateEvent;
import com.deanlib.cabinet.databinding.ActivityUserBinding;
import com.deanlib.cabinet.utils.ConfigManager;
import com.deanlib.cabinet.utils.UserManager;
import com.tencent.mmkv.MMKV;

import org.greenrobot.eventbus.EventBus;

/**
 * 用户
 * Created by Dean on 2022/9/6
 */
public class UserActivity extends BaseActivity<ActivityUserBinding> {
    @Override
    public void initView() {
        binding.btnExit.setOnClickListener(view->{
            UserManager.getInstance().exit();
            AppDatabase.getDaoSession().clear();
            AppDatabase.getDaoSession().getResourceDao().deleteAll();
            MMKV.defaultMMKV().clearAll();
            EventBus.getDefault().postSticky(new UserStateEvent());
            finish();
        });
    }

    @Override
    public void loadData() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_user;
    }
}
